GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c8bf84...8e4dac )
by Stefano
02:11
created

program.action   A

Complexity

Conditions 1
Paths 5

Size

Total Lines 60

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 1
c 3
b 1
f 0
nc 5
dl 0
loc 60
rs 9.5555
nop 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A fs.readFile(ꞌconfig.php.distꞌ) 0 6 2
C fs.readFile(ꞌconfig.php.distꞌ) 0 50 9

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
var shell = require('shelljs');
2
var chalk = require('chalk');
3
var fs = require('fs');
4
5
var enviroment = process.env.npm_package_config_enviroment;
6
7
shell.echo('Compile Workspace ('+enviroment+')');
8
9
shell.cd('applications/workspace/');
10
11
fs.readFile('config.php.dist', 'utf8', function (err,data) {
12
13
  if (err) {
14
    process.stderr.write(chalk.red("Errore in lettura: "+err) + "\n");
15
    process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
16
  }
17
18
  var result;
19
  if ( enviroment === 'dev' ){
20
    result = data.replace(/##TYPE##/g, 'sqlite');
21
    result = result.replace(/##HOST##/g, 'ROOT_PATH.\'/../database/workspace.sqlite\'');
22
    result = result.replace(/##DBNAME##/g, '');
23
    result = result.replace(/##PASSWORD##/g, '');
24
    result = result.replace(/##USERNAME##/g, '');
25
    result = result.replace(/##LOGLEVEL##/g, '\\Monolog\\Logger::DEBUG');
26
  } else if ( enviroment === 'vagrant' ){
27
    result = data.replace(/##TYPE##/g, 'mysql');
28
    result = result.replace(/##HOST##/g, '\'localhost\'');
29
    result = result.replace(/##DBNAME##/g, 'workspace');
30
    result = result.replace(/##PASSWORD##/g, 'workspace');
31
    result = result.replace(/##USERNAME##/g, 'workspace');
32
    result = result.replace(/##LOGLEVEL##/g, '\\Monolog\\Logger::DEBUG');
33
  } else {
34
    // STAGING / PROD
35
    result = data.replace(/##TYPE##/g, 'mysql');
36
    if (
37
      !process.env.npm_package_config_database_host ||
38
      !process.env.npm_package_config_database_host ||
39
      !process.env.npm_package_config_database_dbname ||
40
      !process.env.npm_package_config_database_password ||
41
      !process.env.npm_package_config_database_username
42
    ) {
43
      process.stderr.write(chalk.red("Errore manca la configurazione in .npmrc") + "\n");
44
      process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
45
    }
46
    result = result.replace(/##HOST##/g, '\''+process.env.npm_package_config_database_host+'\'');
47
    result = result.replace(/##DBNAME##/g, process.env.npm_package_config_database_dbname);
48
    result = result.replace(/##PASSWORD##/g, process.env.npm_package_config_database_password);
49
    result = result.replace(/##USERNAME##/g, process.env.npm_package_config_database_username);
50
    result = result.replace(/##LOGLEVEL##/g, '\\Monolog\\Logger::INFO');
51
  }
52
53
54
  fs.writeFile('config.php', result, 'utf8', function (err) {
55
     if (err) {
56
       process.stderr.write(chalk.red("Errore in scrittura: "+err));
57
       process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
58
     }
59
  });
60
});
61